const Redis = require('ioredis')

const redis = new Redis({
    port: 6379,
    host: '127.0.0.1'
})

const setRedis = (key, value) => {
    redis.set(key, value, "EX", 60)
}

const getRedis = (key) => {
    return new Promise((resolve, reject) => {
        redis.get(key, (err, result) => {
            if (err) {
                reject(err)
            }
            else {
                resolve(result)
            }
        })
    })

}

module.exports = {
    setRedis, getRedis
}